

const initState = {
  list: [],
  DormitoryList: [],
  zrs: '',
  DormitoryNo: '',
  dataList: [],
};
function dormitoryReducer(state = initState, action) {
  state = JSON.parse(JSON.stringify(state));
  let { type, payload } = action;
  switch (type) {
    case "zrs":
      state.zrs = payload.inset;
      state.DormitoryNo = payload.DormitoryNo;
      state.dataList.push(payload.val);
      if (state.dataList.length >= 2) {
        state.dataList = state.dataList.slice(0, 1)
      }
      break;
    case "getlist":
      state.dataList = payload;
      break;
    case "DormitoryList":
      state.DormitoryList = payload;
      break;
    case "xgshopdata":
      state.dataList = payload;
      break;
    case "zhirishang":
      state.dataList = payload;
      break;
    case "xougaipingji":
      state.dataList = payload;
      break;
    case "remove":
      state.dataList = payload;
      break;
    case "tihuan":
      state.dataList = payload;
      console.log(payload);
      break;
  }
  return state;
}
export default dormitoryReducer;
